<template>
  <div>
    <el-tabs :tab-position="'left'" style="height: 200px;" @tab-click="checktab">
      <el-tab-pane :label="'第'+e.mid+'次做题'" v-for="e in errorsList" :key="e.mid">
        <el-table
          :data="e.errors"
          stripe
          style="width: 100%">
          <el-table-column
            prop="date"
            label="日期"
            width="180">
          </el-table-column>
          <el-table-column
            prop="name"
            label="姓名"
            width="180">
          </el-table-column>
          <el-table-column
            prop="answer"
            label="我的答案">
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data(){
    return {
      errorsList:[]
    }
  },
  methods:{
    checktab(el){
      console.log(el);
    },
    init(){
      let userinfo = JSON.parse(localStorage.getItem('user')||"[]")
      if(userinfo.length>0){
        let uid = userinfo[0][0].userinfoId
        this.$ajax({
          url:'exam/geterrors/'+uid,
          method:'get'
        }).then(resp=>{
          if(resp.data.status==1){
            let errorsList = resp.data.message
            errorsList.forEach(item=>{
              item.errors = JSON.parse(item.errors)
            })
            this.errorsList = errorsList
          }
        })
      }
    }
  },
  created(){
    this.init()
  }
}
</script>

<style>

</style>